package org.example.springioc;

import lombok.val;
import org.example.springioc.Service.UserService;
import org.example.springioc.component.UserConponent;
import org.example.springioc.config.UserConfig;
import org.example.springioc.controller.HelloController;
import org.example.springioc.controller.UController;
import org.example.springioc.controller.UserController;
import org.example.springioc.model.UserInfo;
import org.example.springioc.repo.UserRepo;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.boot.SpringApplication;

import java.beans.Introspector;

@SpringBootApplication
public class DemoApplication {
    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(DemoApplication.class,args);

        UserController bean = context.getBean(UserController.class);
        bean.sayHi();
//        HelloController bean = context.getBean(HelloController.class);
//        System.out.println(bean);
//        bean.sayHi();
//
//        HelloController helloController = (HelloController)context.getBean("helloController");
//        System.out.println(helloController);
//        helloController.sayHi();
//
//        HelloController helloController1 = context.getBean("helloController", HelloController.class);
//        System.out.println(helloController1);
//        helloController1.sayHi();
        //三种创建方式 是一个bean
//        UController bean = context.getBean(UController.class);
//        System.out.println(bean);
//        bean.sayHi();
//
//        UController uController  = (UController)context.getBean("UController");
//        System.out.println(uController);
//        uController.sayHi();
//
//        UController uController1 = context.getBean("UController", UController.class);
//        System.out.println(uController1);
//        uController1.sayHi();

        //打印bean的名字
        //System.out.println(Introspector.decapitalize("HelloController"));

       /* UserService bean = context.getBean(UserService.class);
        bean.doService();
        UserConponent bean1 = context.getBean(UserConponent.class);
        bean1.doComponent();
        UserConfig bean2 = context.getBean(UserConfig.class);
        bean2.doConfig();
        UserRepo bean3 = context.getBean(UserRepo.class);
        bean3.doRepo();*/

//        UserInfo bean = (UserInfo) context.getBean("userInfo");
//        System.out.println(bean);

    }
}
